<?php
	global $_W,$_GPC;
	if($_W['role']&&$_W['isajax']){
		$tid = intval($_GPC['tid']);
		$data = array();
		$start = strtotime(date('Y-m-d',$_W['timestamp']).' '.$_GPC['start']);
		$end = strtotime(date('Y-m-d',$_W['timestamp']).' '.$_GPC['end']);
		$rest_start = strtotime(date('Y-m-d',$_W['timestamp']).' '.$_GPC['rest_start']);
		$rest_end = strtotime(date('Y-m-d',$_W['timestamp']).' '.$_GPC['rest_end']);
		if($start>$end){
			exit(json_encode(array('status'=>-1,'msg'=>'上班时间不能大于下班时间')));
		}
		if($rest_start>$rest_end){
			exit(json_encode(array('status'=>-1,'msg'=>'中场休息开始时间不能大于结束时间')));
		}
		$rest_week = array_unique(explode('oOo', trim($_GPC['rest_week'])));
		$data = array(
			'uniacid'=>$_W['uniacid'],
			'template_name'=>$_GPC['template_name'],
			'start'=>$_GPC['start'],
			'end'=>$_GPC['end'],
			'timeinterval'=>trim($_GPC['timeinterval']),
			'rest_start'=>$_GPC['rest_start'],
			'rest_end'=>$_GPC['rest_end'],
			'rest_week'=>json_encode($rest_week)
		);
		$up = pdo_update('mii_ang_timetemplate',$data,array('tid'=>$tid));
		if($up){
			exit(json_encode(array('status'=>1,'msg'=>'保存成功')));
		}else{
			exit(json_encode(array('status'=>-1,'msg'=>'保存失败')));
		}
	}else{
		exit(json_encode(array('status'=>-1,'msg'=>'没有操作权限')));
	}


?>